-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New API for downloading LDML files from projects that allow sharing WS data #1309
Conversation
Unfortunately it looks as though we won't be able to use ZipArchive to add files to the output stream asynchronously as they come in: we'd probably run into this issue where ZipArchive tries to write the end-of-zipfile directory synchronously when it's disposed, but Kestrel doesn't allow synchronous writes to its HTTP output stream. So we might have to extract everything, then send the zip file separately. Which means that the HTTP connection might time out, so it's possible we'll have to make two API endpoints, one to prepare the zip file and one to download it. Testing required. |
Will return 403 Forbidden if project does not allow sharing ws data with SLDR. Will also return same 403 Forbidden error code if project does not exist, to avoid possibly leaking project codes. If project exists and allows data sharing, command will return a zipfile containing CachedSettings/WritingSystems/*.ldml from the tip revision.
8888014
to
ae60963
Compare
Rebased on top of current develop since it's been a month since this was started, and a lot has changed on the develop branch in that time. |
Alas, this fails (when a ProjectController method is added to call PrepareLdmlZip) with "System.InvalidOperationException: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead." We'll have to change this to prepare the entire zip file first, then send it.
This is less efficient, but the only method that actually works given the current state of the ZipFile / ZipArchive code in .NET.
Now working; marking as ready for review. Not ready to merge yet, as there are several discussion items (marked with TODO comments) in this PR, such as what the permission structure should be. But it's tested and working. To test locally, you'll need to get a project with
If all went well, the zipfile should contain a folder named for a project ID at the root. If you get a 22-byte zip file that's empty, then something went wrong. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a bunch of feedback, let me know if I missed any questions you still have.
One thought is to return 404 if there's no projects found, that should make it clear what's going on rather than an empty zip being an expected result.
Can safely add an optional `delay` parameter to LexJob instead
Zip file now has timestamp in name, so this API can be called multiple times within a 4-hour period without interfering with other calls.
@hahn-kev wrote:
All comments addressed, and commit e7b98d8 sets it up to return 404 instead of an empty zip, as well as putting a UTC timestamp into the filename so that it's more obvious when the API call was run. This is ready for re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, one minor nitpick but feel free to merge this in
Fixes #1306.
To test locally, you'll need to get a project with
addToSldr="true"
in its writing system configuration. None of our default test projects have that, but you can add that with the following method:kubectl --context=docker-desktop exec -it deploy/hg -- bash
cd /var/hg/repos/s/sena-3
or/e/elawa-dev-flex
hg co tip
to populate the repo's working directoryCachedSettings/SharedSettings/LexiconSettings.plsx
file<WritingSystems>
line to<WritingSystems addToSldr="true">
hg commit -m "Add to SLDR"
hg config --edit
to set your usernamehg co null
to empty the working directory now that the commit is in the repoIf all went well, the zipfile should contain a folder named for a project ID at the root. If you get a 22-byte zip file that's empty, then something went wrong.
Currently the directory structure for each project looks like this:
{project ID}/CachedSettings/WritingSystemStore/lots of .ldml files
Do we want to change that to just this?
{project ID}/lots of .ldml files
Discussion items
CachedSettings/WritingSystemStore/
?